import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import DefineOptions from 'unplugin-vue-define-options/dist/vite'
import vueJsx from '@vitejs/plugin-vue-jsx'

import path from 'path'
// import { quRoot, pkgRoot } from '../build/index'

const quRoot = path.resolve(__dirname, '../packages/qing-design')
const pkgRoot = path.resolve(__dirname, '../packages')

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(), DefineOptions(), vueJsx()],
  resolve: {
    alias: [
      {
        find: /^qing-design(\/(es|lib))?$/,
        replacement: path.resolve(quRoot, 'index.ts')
      },
      {
        find: /^qing-design\/(es|lib)\/(.*)$/,
        replacement: `${pkgRoot}/$2`
      }
    ]
  }
})
